package org.simplespringframework.mvc.render.impl;

import org.simplespringframework.mvc.RequestProcessorChain;
import org.simplespringframework.mvc.render.ResultRender;

import javax.servlet.http.HttpServletResponse;

/**
 * @BelongsProject: simpleframework
 * @BelongsPackage: org.simplespringframework.mvc.render.impl
 * @Author: xshang
 * @CreateTime: 2023-06-28  16:42
 * @Description: 资源找不到时用到的渲染器
 * @Version: 1.0
 */
public class ResourceNotFoundResultRender implements ResultRender {

    private final String httpMethod;
    private final String httpPath;

    public ResourceNotFoundResultRender(String httpMethod, String httpPath) {
        this.httpMethod = httpMethod;
        this.httpPath = httpPath;
    }

    @Override
    public void render(RequestProcessorChain requestProcessorChain) throws Exception {
        requestProcessorChain.getResponse().sendError(HttpServletResponse.SC_NOT_FOUND,
                "获取不到对应的资源：请求路径[" + httpPath + "]" + "请求方法[" + httpMethod + "]");
    }
}
